package com.e7.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Encoder {
	
	public static void main(String[] args){
		System.out.println(Encoder.encode("wml199039@gmail.com"));
	}
	
	public static String encode(String plainText) {
		try {
			MessageDigest md = MessageDigest.getInstance("MD5");
			md.update(plainText.getBytes());
			byte b[] = md.digest();
			StringBuffer buf = new StringBuffer("");
			for (int j = 0; j < b.length; j++) {
				int i = b[j];
				if (i < 0)
					i += 256;
				if (i < 16)
					buf.append("0");
				buf.append(Integer.toHexString(i));
			}
			String str = buf.toString();
			return str;
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
		return null;
	}
}